package demo.IOStream;

import java.io.*;

/**
 * @Auther: hjy(lc))
 * @Date: 2022/8/13-08-13-9:47
 * @Description：demo.IOStream
 */
public class Read_write {
    public static void main(String[] args) {
        File file = new File(".\\hello.txt");
        FileInputStream in = null;
        FileOutputStream out = null;
        try {
             in = new FileInputStream(file);
             out = new FileOutputStream(file);
            byte[] b = new byte[1024];
            b = "123456".getBytes();

            out.write(b);
            out.flush();
            int len = -1;
             while((len = in.read(b))!=-1){
                 System.out.write(b,0,len);
                 System.out.flush();
             }

        } catch (IOException e) {
            e.printStackTrace();
        }finally {
            try {
                in.close();
                out.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }

    }
}
